﻿<!DOCTYPE html>

<html lang="en" xmlns="http://www.w3.org/1999/xhtml">
<head>
    <meta charset="utf-8" />
    <title>JS</title>
</head>
<body>
    
    <h1>JS基础2</h1>
    <a id="link1">超链接</a>
    
    <button onclick="changeLinkText()">修改超链接文本</button>

    <button onclick="goTobaidu()">跳转到百度</button>

    <button onclick="sayHello()">打印文字</button>

    <button onclick="confirmPromp()">弹出确认框</button>

    <script>

        function confirmPromp() {
            var r = window.confirm("确认要弹框?");
            if (r) {
                alert("确认按钮被点击");
            }
        }

        function sayHello() {
            alert("hello, everyone");
        }

        function goTobaidu() {
            location.href = "https://www.baidu.com";
        }

        function changeLinkText() {
            var linkObj = document.getElementById("link1");
            console.log(linkObj);
            linkObj.innerHTML = "百度";
        }
        

    </script>


</body>
</html>